package com.b2c.ftysys.vo;

import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.b2c.ftysys.helper.ObjectUtils;

public class OrderVo extends BaseVo {
	/**
	 * 订单Id
	 */
	private Long orderid;

	/**
	 * 客户订单编号(采购单号)
	 */
	private String cmtorderid;

	/**
	 * 采购日期
	 */
	private Date orderdate;

	/**
	 * 付款方式
	 */
	private String ordertype;

	/**
	 * 客户采购仓库
	 */
	private String cmtwarehouse;

	/**
	 * 订单状态
	 */
	private String orderstatus;

	/**
	 * 付款方式
	 */
	private String paytype;

	/**
	 * 采购备注
	 */
	private String remark;

	/**
	 * 订单产品条目
	 */
	private Set<OrderItemVo> orderItems;
	
	/**
	 * 订购产品总数
	 */
    private Integer totalNum;
    
    /**
     * 订单原件名称
     */
    private String fileAddr;
    
	/**
	 * 添加item
	 * 
	 * @param orderItem
	 */
	public void addItem(OrderItemVo orderItem) {
		if (null == orderItems)
			orderItems = new HashSet<OrderItemVo>();
		orderItem.setArrivedate(this.orderdate);
		orderItem.setOrderid(this.cmtorderid);//对应关系
		orderItems.add(orderItem);
	}

	/**
	 * 删除Item
	 * 
	 * @param orderItem
	 */
	public void removeItem(OrderItemVo orderItem) {
		if (null != orderItems && orderItems.contains(orderItem)) {
			orderItems.remove(orderItem);
		}
	}

	public Long getOrderid() {
		return orderid;
	}

	public void setOrderid(Long orderid) {
		this.orderid = orderid;
	}

	public String getCmtorderid() {
		return cmtorderid;
	}

	public void setCmtorderid(String cmtorderid) {
		this.cmtorderid = cmtorderid;
	}

	public Date getOrderdate() {
		return orderdate;
	}

	public void setOrderdate(Date orderdate) {
		this.orderdate = orderdate;
	}

	public String getOrdertype() {
		return ordertype;
	}

	public void setOrdertype(String ordertype) {
		this.ordertype = ordertype;
	}

	public String getCmtwarehouse() {
		return cmtwarehouse;
	}

	public void setCmtwarehouse(String cmtwarehouse) {
		this.cmtwarehouse = cmtwarehouse;
	}

	public String getOrderstatus() {
		return orderstatus;
	}

	public void setOrderstatus(String orderstatus) {
		this.orderstatus = orderstatus;
	}

	public String getPaytype() {
		return paytype;
	}

	public void setPaytype(String paytype) {
		this.paytype = paytype;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Set<OrderItemVo> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(Set<OrderItemVo> orderItems) {
		this.orderItems = orderItems;
	}

	public String toString() {
		ToStringBuilder stringBuilder = new ToStringBuilder(this);
		for (Method method : getClass().getDeclaredMethods()) {
			try {
				if (method.getName().indexOf("get") == 0) {
					stringBuilder.append(method.getName() + "-->"
							+ ObjectUtils.invokeMethod(this, method.getName()));
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return stringBuilder.toString();
	}

	public Integer getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(Integer totalNum) {
		this.totalNum = totalNum;
	}

	public String getFileAddr() {
		return fileAddr;
	}

	public void setFileAddr(String fileAddr) {
		this.fileAddr = fileAddr;
	}
}
